package com.fzu.messageservice.controller;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.fzu.commonutil.ImResult;
import com.fzu.commonutil.entity.ImChatUserMessage;
import com.fzu.commonutil.util.ImUtil;
import com.fzu.messageservice.service.ImChatUserMessageService;
import lombok.extern.slf4j.Slf4j;
import org.hibernate.validator.internal.constraintvalidators.bv.time.past.PastValidatorForYear;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.util.CollectionUtils;
import org.springframework.web.bind.annotation.*;

import java.util.Collections;
import java.util.List;
import java.util.stream.Collectors;


/**
 * 单聊记录(ImChatUserMessage)表控制层
 *
 * @author Answer
 * @since 2023-04-04 21:45:59
 */
@Slf4j
@RestController
@RequestMapping("imChatUserMessage")
public class ImChatUserMessageController {
    /**
     * 服务对象
     */
    @Autowired
    private ImChatUserMessageService imChatUserMessageService;

    /**
     * 获取朋友消息（只获取前四十条）
     */
    @GetMapping("/listFriendMessage")
    public ImResult<Page> listFriendMessage(@RequestParam(value = "current", defaultValue = "1") Long current,
                                            @RequestParam(value = "size", defaultValue = "40") Long size,
                                            @RequestParam(value = "friendId") Integer friendId) {
        return imChatUserMessageService.listFriendMessage(current, size, friendId);
    }

    @GetMapping("/getUnReadMessage")
    public ImResult<Integer> getUnReadMessage() {
        return imChatUserMessageService.getUnReadMessage();
    }
}

